﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class shiti_result : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["sTittle"] = "查询/修改试题";
            //zxdurl = "shiti_result.aspx?zxdpkey=" + txtSelect.Text.Trim() + "&zxdpkechengid=" + txtid.Text.Trim() + "&zxdpname=" + txtname.Text.Trim();
            txtid.Text = Request.QueryString["zxdpkechengid"];
            txtname.Text = Request.QueryString["zxdpname"];
            txtSelect.Text = Request.QueryString["zxdpkey"];
            ddlType1.SelectedValue = Request.QueryString["zxdptype"];
            if (txtSelect.Text == "")
            {
                string noth = "SELECT * FROM [kecheng_question_taoti] WHERE ([que_lessonid] =" + txtid.Text.Trim() + ") order by que_type,id";
                SDSquestion.SelectCommand = noth;
            }
            else
            {
                string noth1="SELECT * FROM [kecheng_question_taoti] WHERE ([que_lessonid] =" + txtid.Text.Trim() + " AND " + ddlType1.SelectedValue + " Like '%" + txtSelect.Text + "%') order by que_type,id";
                SDSquestion.SelectCommand = noth1;
            }
        }
    }
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        if (txtSelect.Text == "")
        {
            string noth = "SELECT * FROM [kecheng_question_taoti] WHERE ([que_lessonid] =" + txtid.Text.Trim() + ") order by que_type,id";
            SDSquestion.SelectCommand = noth;
        }
        else
        {
            string noth1 = "SELECT * FROM [kecheng_question_taoti] WHERE ([que_lessonid] =" + txtid.Text.Trim() + " AND " + ddlType1.SelectedValue + " Like '%" + txtSelect.Text + "%') order by que_type,id";
            SDSquestion.SelectCommand = noth1;
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //dataconn.eccom("delete from  tb_Questions where ID='" + gvExamTitle.DataKeys[e.RowIndex].Value + "'");
        Conn zconn = new Conn();
        string zsql = "delete from  tb_Questions where id=" + gvExamTitle.DataKeys[e.RowIndex]["id"].ToString();
        zconn.ExeSql(zsql);
        zconn.Dispose();
        string zxdurl;
        zxdurl = "shiti_result.aspx?zxdpkey=" + txtSelect.Text.Trim() + "&zxdpkechengid=" + txtid.Text.Trim() + "&zxdpname=" + txtname.Text.Trim() + "&zxdptype=" + ddlType1.SelectedValue;
        Response.Redirect(zxdurl);
        //Page.Response.Redirect("shiti.aspx?zid=" + txtid.Text.Trim() + "&zname=" + txtname.Text.Trim());

    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //gvExamTitle.PageIndex = e.NewPageIndex;
        //dataconn.ecadabind(gvExamTitle, "Select * From Timu_Taoti_Kcheng_view Where "
        //        + ddlType.SelectedValue + " Like '%" + txtSelect.Text + "%'");
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    e.Row.Cells[3].Text = Convert.ToString(Convert.ToDateTime(e.Row.Cells[3].Text).ToShortDateString());
        //}
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Page.Response.Redirect("shiti.aspx?zid=" + txtid.Text.Trim() + "&zname=" + txtname.Text.Trim());
    }
}
